
#include "stdafx.h"
#include "OzZerror.h"
#include "OS.h"
#include <string>

#include <map>
using std::map;

namespace oc
{

Error::Error()
:szBETASTRING(NULL), nLine(0), szFile(0), szFunction(0), pointer(NULL)
{}

Error::Error(int lookup, void* p, const long line, const char* file, const char* func)
: szBETASTRING(NULL)
, tableLookup(lookup)
, pointer(p)
, nLine(line)
, szFile(file)
, szFunction(func)
{
	// todo: do lookup in stringtable here
}
/*BETA*/Error::Error(const char* szBETA, const long line, const char* file, const char* func)
	: szBETASTRING(szBETA)
	, nLine(line)
	, szFile(file)
	, szFunction(func){}

Error::Error(int type, DWORD btns, const char* pos, const char* reason, const char* userinfo, void* p, const long line, const char* file, const char* func)
: szBETASTRING(NULL)
, tableLookup(0)
, type(type)
, msgbtns(btns)
, szPos(pos)
, szReason(reason)
, szForUser(userinfo)
, pointer(p)
, nLine(line)
, szFile(file)
, szFunction(func)
{}


DWORD	HandleError(Error err)
{
	std::string msg;
	msg  = "Following Error Occured:";
	msg += err.szBETASTRING;
	msg += "\nWanted to do: ";
	msg += err.szPos;
	msg += "\nBut that inhibited me: ";
	msg += err.szReason;
	msg += "\nTo avoid that you can do the following: ";
	msg += err.szForUser;
	msg += "\n\nAdvanced Information:";
	msg += 
		"\nFile: ";
	msg += err.szFile;
	msg +=
		"\nLine: ";
	char szBuff[8];
	sprintf_s(szBuff, 8, "%d", err.nLine);
	msg += szBuff;
	msg +=
		"\nFunction";
	msg += err.szFunction;
	return OSMsg(msg.c_str(), err.msgbtns);
}

} //namespace oc